/* 
页面初始化，计算rem
*/
(function () {
    function buildRem() {
        let designSize = 1920; // 设计图尺寸            
        let html = document.documentElement;
        let wW = html.clientWidth;// 窗口宽度
        let rem = wW * 100 / designSize;
        html.style.fontSize = rem + 'px';
    }
    buildRem()
    // 监听窗口尺寸
    window.onresize = buildRem
}
)();
/* 
动态插header
*/
(function () {
    const navData = [
        {
            title: "首页",
            url: "index.html",
        },
        {
            title: "作品展示",
            url: "portfplio.html",
        },
        {
            title: "博客",
            url: "blogs.html",
        },
        {
            title: "我的简历",
            url: "about.html",
        },
        {
            title: "联系我",
            url: "contact.html",
        }
    ]
    const header = document.getElementById('header')
    const insertNav = function () {
        let res = ''
        navData.forEach(nav => {
            res += `<li class="${getPageName()==nav.url?"active":""}"><a href="${nav.url}">${nav.title}</a></li>`
        })
        return res
    }
    header.insertAdjacentHTML('afterbegin', `
  <div class="container flex wrap">
            <a href="./index.html"><img class="logo" src="./imgs/logo.png" alt=""></a>
            <nav id="navbar">
                <ul>${insertNav()}
                </ul>
            </nav>
        </div>
`)
    // 加亮
    function getPageName() {
        const pathArr = location.pathname.split('/')
        return pathArr[pathArr.length - 1]
    }
})();


/* 
导航栏加亮
*/
(function () {

}
)();


(function () {


})();


(function () {


})();